/**
 * 
 */
package com.nextive.interview.dao.sqlite;

import android.content.Context;
import android.database.Cursor;

import com.nextive.interview.dao.UserInfoDao;

/**
 * @author Cesar Roman
 *
 */
public class SqLiteUserInfoDao extends SqLiteHelperDao implements UserInfoDao {

    private static final String DATABASE_NAME = "next_app_test_db";
    private static final String DATABASE_TABLE = "user_info";
    private static final int DATABASE_VERSION = 2;
    private static final String DATABASE_DROP = "DROP TABLE IF EXISTS " + DATABASE_TABLE;
    private static final String DATABASE_CREATE =
        "create table " + DATABASE_TABLE + " (" + UserInfoDao.ID_KEY 
        + " integer primary key autoincrement, " + UserInfoDao.NAME_KEY 
        + " text not null, " + UserInfoDao.EMAIL_KEY + " text not null, " 
        + UserInfoDao.RECIPIENT_KEY + " text not null, " + UserInfoDao.OPTION_KEY 
        + " char not null, " + UserInfoDao.HAS_ACCESSED_KEY + " boolean not null);";

    public SqLiteUserInfoDao(Context context) {
    	
		super(context);
		
	}

	@Override
	public Cursor getUserFirstAccess() {
		
		open();
		return getDatabase().query(DATABASE_TABLE, new String[] {}, null, 
				null, null, null, null);
		
	}

	@Override
	protected String getDBName() {
		
		return DATABASE_NAME;
		
	}

	@Override
	protected int getDBVersion() {
		
		return DATABASE_VERSION;
		
	}

	@Override
	protected String getDBCreateStatement() {
		
		return DATABASE_CREATE;
		
	}

	@Override
	protected String getDBDropStatement() {
		
		return DATABASE_DROP;
		
	}

}
